﻿namespace Polenter.Mcm
{
    /// <summary>
    ///     Recommended for all simple scenarios. Contains only one single message channel.
    ///     This class is sealed.
    ///     For advanced scenario a descendant of ComponentContainer should be created containting more message channels
    ///     (i.e. for error broadcast or other important events)
    /// </summary>
    public sealed class ComponentContainerWithSingleMessageChannel : ComponentContainer
    {
        /// <summary>
        ///     Name of the Messages - message channel
        /// </summary>
        public const string MessagesChannelName = "Messages";

        private MessageChannel _messages;

        /// <summary>
        /// </summary>
        public ComponentContainerWithSingleMessageChannel()
        {
        }

        /// <summary>
        ///     Is used for the message broadcast
        /// </summary>
        public MessageChannel Messages
        {
            get
            {
                if (_messages == null)
                {
                    _messages = new MessageChannel(MessagesChannelName);
                }
                return _messages;
            }
        }
    }
}